/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * escogerLienzos.java
 *
 * Created on 22-abr-2013, 15:49:26
 */
package EditorImagenes;

import java.awt.Color;
import javax.swing.DefaultListModel;
import proyecto1compi1.Escenario;
import proyecto1compi1.Interfaz;
import proyecto1compi1.pintarEscenario;

/**
 *
 * @author Usuario
 */
public class escogerLienzos extends javax.swing.JFrame {
    
      private DefaultListModel modelo=new DefaultListModel();
      
    /** Creates new form escogerLienzos */
    public escogerLienzos() {
        initComponents();
        
        llenar();
    }
    

 public void llenar () {
    
  
     for(int i=0; i<Interfaz.listaEscenarios.size(); i++){
   
    modelo.addElement(Interfaz.listaEscenarios.get(i).nombre);
    
    }
    
    jList1.setModel(modelo);
  
 
}
 
 
 public void  pintar(String nombreEscenario){
 
 int tamanio=2;
        Color color=new Color(255,255,255);
        String nombreImagen="";
        String extension="";
                
        for(pintarEscenario aux2: Interfaz.listadoPintarEscenario){
            if(aux2.nombreEscenario.equals(nombreEscenario)){
         	   
	for(Escenario aux:Interfaz.listaEscenarios ){
            
            if(aux2.nombreEscenario.equals(aux.nombre)){
                nombreEscenario=aux.nombre;
                System.out.println(aux.nombre);	
                tamanio=aux.dimension.intValue(); 
                
										System.out.println(aux.nombreImg);
                                                                                nombreImagen=aux.nombreImg;
										System.out.println(aux.tipos);
                                                                                extension=aux.tipos;
										System.out.println(aux.fondo);
										System.out.println(aux.cuadro);
										System.out.println(aux.dimension);
										System.out.println(aux.imagen);
										System.out.println(aux.rojo);
										System.out.println(aux.verde);
                   if(aux.colorHex==null){
                 color=new Color(Integer.valueOf(aux.rojo),Integer.valueOf(aux.verde),Integer.valueOf(aux.azul));
                   }else{
                     color = Color.decode("#"+aux.colorHex);
                   }
                 System.out.println(color);
             try{
             
             }catch(Exception e){
             
             }    
             
										System.out.println(aux.azul);
										System.out.println(aux.colorHex);
										
            
            }
										
									} 
			
        
          Ventana nueva =new Ventana(tamanio,color,nombreEscenario,nombreImagen,extension);   
       
        }
        }
        
    
 }

    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jScrollPane1.setViewportView(jList1);

        jButton1.setText("Ok");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(91, 91, 91)
                        .addComponent(jButton1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(53, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(53, 53, 53)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38)
                .addComponent(jButton1)
                .addContainerGap(25, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
      
    if(this.jList1.getSelectedIndex()!= -1){
       this.setVisible(false);
        
       
       String nombreLienzo=this.jList1.getSelectedValue().toString();
       pintar(nombreLienzo);
          
    }
}//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(escogerLienzos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(escogerLienzos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(escogerLienzos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(escogerLienzos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new escogerLienzos().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JList jList1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
